<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>下载</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .box {
            width: 320px;
            height: 320px;
            background-color: #DCDCDC;
            overflow: hidden;
        }
        .box .image {
            width: 120px;
            height: 120px;
            margin: 50px auto 0 auto;
            display: block;
        }
        .box #mydiv {
            width: 160px;
            height: 40px;
            line-height: 40px;
            background-color: #fafffa;
            text-align: center;
            border: 1px solid #43c45b;
            color: #348e43;
            border-radius: 5px;
            font-size: 16px;
            margin: 12px 80px 0;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="box">
        <img class="image" src="../../img/scanner.png" />
        <div id="mydiv">立即下载</div>
    </div>

    <script type="text/javascript">
        Object.prototype.addListener = function(ev, fn){
            if(this.attachEvent){
                this.attachEvent('on' + ev, fn);
            }else{
                this.addEventListener(ev, fn, false);
            }
        }

        var mydiv = document.getElementById("mydiv");
        mydiv.addListener('click', down, false);

        let files = [
            '/smartInstall/Debug/Newtonsoft.Json.Compact.dll',
            '/smartInstall/Debug/Newtonsoft.Json.dll',
            '/smartInstall/Debug/Symbol.Barcode2.DesignCF35.dll',
            '/smartInstall/Debug/Symbol.Barcode2.DesignCF35.xml',
            '/smartInstall/Debug/Symbol.dll',
            '/smartInstall/Debug/Symbol.xml'
        ];

        function down(){
            for(var i = 0; i < files.length; i++){
                if(isIE()){
                    var elemIF = document.createElement("iframe");
                    elemIF.src = files[i];
                    elemIF.style.display = "none";
                    document.body.appendChild(elemIF);
                    elemIF.click()
                }else{
                    let a = document.createElement('a');
                    let e = document.createEvent('MouseEvents');
                    e.initEvent('click', false, false);
                    a.href = files[i];
                    a.download = '';
                    a.dispatchEvent(e);
                }
            }
        }
        //判断IE浏览器
        function isIE(){
            if(!!window.ActiveXObject || 'ActiveXObject' in window){
                return true;
            }else{
                return false;
            }
        }
    </script>
</body>
</html>
